﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AutoAddClient
{
    public class DeviceRandService
    {
        public DeviceRandService(DotNet.Random.DateTime.DateTimeRandService dateTime,
            DeviceTokenRandService token, DeviceNameRandService name)
        {
            if (token == null)
            {
                throw new ArgumentNullException("token is null");
            }
            if (name == null)
            {
                throw new ArgumentNullException("name is null");
            }
            this.DateTimeRandService = dateTime;
            this.DeviceNameRandService = name;
            this.DeviceTokenRandService = token;
        }

        public DotNet.Random.DateTime.DateTimeRandService DateTimeRandService { get; set; }

        public AutoAddClient.DeviceTokenRandService DeviceTokenRandService { get; set; }

        public AutoAddClient.DeviceNameRandService DeviceNameRandService { get; set; }

        public Domain.Entity.MobileClient Rand()
        {
            var model = new Domain.Entity.MobileClient();
            model.AddTime = (this.DateTimeRandService != null ? this.DateTimeRandService.Rand() : DotNet.Random.RandService.RandDateTimeCurrentYearMonthDay());
            model.DeviceToken = this.DeviceTokenRandService.Rand();
            model.IpAddress = "127.0.0.1";
            model.Name = this.DeviceNameRandService.Rand();
            model.Remark = model.Name;
            model.SortNum = -1;
            model.State = true;
            return model;
        }
    }
}
